﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing;

namespace ElectronicsMarket_Desktop
{
   public class PictureCovert
    {
       MemoryStream stream;
       Image pic;

       public Image Pic
       {
           get { return pic; }
           set { pic = value; }
       }
       byte[] picture_byte;

       public byte[] Picture_byte
       {
           get { return picture_byte; }
           set { picture_byte = value; }
       }
       public PictureCovert()
       {

       }
       public PictureCovert(Image img)
       {
           this.pic = img;
       }
       public PictureCovert(byte[] pic_byte)
       {
           this.picture_byte = pic_byte;
       }
       public void PicturrConvertToBinary()
       {
           stream = new MemoryStream();
           pic.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
           Picture_byte = stream.ToArray();

       }
       public void BinaryconvertToPicture()
       {
           try
           {
               stream = new MemoryStream(picture_byte);
               pic = Image.FromStream(stream);
           }
           catch
           {
           }
          
       }
    }
}
